package com.nervenets.web.validation;

import com.nervenets.utils.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by joe on 17-3-12.
 */
public final class ValidateResult implements Serializable {
    private boolean valid;
    private List<String> messages;

    public ValidateResult() {
    }

    public ValidateResult(boolean valid) {
        this.valid = valid;
    }

    public void addMessage(String message) {
        if (null == this.messages) this.messages = new ArrayList<String>();
        this.messages.add(message);
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }

    public List<String> getMessages() {
        return messages;
    }

    public void setMessages(List<String> messages) {
        this.messages = messages;
    }

    public String getMessageString() {
        return StringUtils.toJson(messages);
    }
}
